//gameRoom 需要和服务器数据保持一致，因此拷贝复制为 campaignRoom 作为主观房间
//修改了一个属性：users 由JSON字符串改为js实体
//添加了两个属性：
//   isOnline : 是否是在线游戏
//   isHost : 是否是主机
//用法：构筑战役房间
var campaignRoomEngine = {
	
	CreateCampaignRoom : function(gameRoom, userSet){
		var campaignRoom = DeepClone(gameRoom);
	
		campaignRoom.users = JSON.parse(campaignRoom.users);
		campaignRoom.isHost = campaignRoom.userId == userSet.gameUser.id;//包含单机情况
		campaignRoom.isOnline = false;
		
		if (userSet.user == null)
			return campaignRoom;
		
		for (var idx = 0; idx < campaignRoom.users.length; idx++ ){
			var commonId = campaignRoom.users[idx].commonId;
			if (commonId >= 0 && commonId != userSet.user.id){
				campaignRoom.isOnline = true;
				break;
			}
		}
		return campaignRoom;
	}
};